package the_second_chapter;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 输入两个随机数，产生一个中间数
 * 
 * @author explorati
 *
 */
public class Random {

	public static void main(String[] args) {
		String s = "";
		double a, b, c, max, min;
		System.out.println("请输入第一个数字：");
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		try {
			s = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		a = Double.parseDouble(s);

		System.out.println("请输入第二个数字：");
		BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
		try {
			s = br1.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		b = Double.parseDouble(s);

		Random r = new Random();
		max = Math.max(a, b);
		min = Math.min(a, b);

		c = Math.random() * (max - min) + min;

		System.out.println("产生的随机中间数为：" + c);
	}
}
